<%@ page import="java.util.List" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/5/19
  Time: 11:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<% String path = request.getContextPath();%>
<script src="<%=path%>/static/js/jquery-3.5.1.min.js"></script>
<link href="<%=path%>/static/web/css/my.css" rel="stylesheet" media="screen">
<style>
    .result-content img{
        width: 50px;
        height: 50px;
    }
    .result-content table{
        text-align: center;
    }
</style>
<script>
    $(function () {
        var pageNum = 1;
        var username = null;
        var sex = null;
        var telephone = null;
        initdate(pageNum,username,sex,telephone);
        //点击页码
        $(".result-content").on("click",".list-page a",function () {
            var pageNum = $(this).data("pagenum");
            username = $("#username").val();
            sex = $("#sex").val();
            telephone = $("#telephone").val();
            initdate(pageNum,username,sex,telephone);
        });
        //搜索
        $("#search").click(function () {
           username = $("#username").val();
           if (username=="")
               username = null;
           sex = $("#sex").val();
           if (sex=="")
               sex = null;
           telephone = $("#telephone").val();
           if (telephone=="")
               telephone = null;
           initdate(pageNum,username,sex,telephone);
        });
    });
    //初始化数据
    function initdate(pageNum,username,sex,telephone) {
        $.ajax({
            url:"<%=path%>/manage/userinfo/date",
            type:"get",
            data:{pageNumber:pageNum,username:username,sex:sex,telephone:telephone},
            success:function (resource) {
                $(".result-content").html(resource);
            }
        });
    }
</script>

<script>
   $(function () {
       $(".result-content").on("click",".link-update",function () {
            var id = $(this).attr("id");
            $.get("<%=path%>/manage/userinfo/userinfoDetailed",{id:id},function (data) {
                $("#hideing").html(data);
                $("#hide").css("display","block");
            });


       });
   });
</script>
<script>
    //批量删除
    $(function () {
        batchDel();
    });
    function batchDel() {
        $("#batchDel").click(function () {
           /*var ids= "";
           $(":checked[id='choose']").each(function () {
                var id = $(this).val();
                ids += id+",";
           });
           if (ids!=""){
               ids = ids.substring(0,ids.length-1);
           }
           alert(ids);*/
           var idArr = new Array();
           $(":checked[id='choose']").each(function () {
                idArr.push($(this).val());
           });
           if (idArr.length>0){
               $.get("<%=path%>/manage/userinfo/batchDel",{idArr:idArr.toString()},function () {
                   for (var i=0;i<idArr.length;i++){
                       if ($(":checked[id='choose']").val()==idArr[i]){
                           $(":checked[id='choose']").parent().parent().remove();
                       }
                   }
               }.bind(this));
           }
        });
    }
</script>
<div id="hideing"></div>
<jsp:include page="/manage/inc/header"/>
<jsp:include page="/manage/inc/menu"/>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="<%=path%>/manage/index">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">用户管理</span></div>
        </div>
        <div class="search-wrap">
            <div class="search-content">
                    <table class="search-tab">
                        <tr>
                            <td>${requestScope.userinfo.username}</td>
                            <td><input class="common-text" placeholder="姓名" name="username" value="" id="username" type="text"></td>
                            <td><input class="common-text" placeholder="性别" name="sex" value="" id="sex" type="text"></td>
                            <td><input class="common-text" placeholder="联系方式" name="telephone" value="" id="telephone" type="text"></td>
                            <td><input class="btn btn-primary btn2" id="search" value="查询" type="button"></td>
                        </tr>
                    </table>
            </div>
        </div>
        <div class="result-wrap">

                <div class="result-title">
                    <div class="result-list">
                        <%--<a href="insert.html"><i class="icon-font"></i>新增作品</a>--%>
                        <a id="batchDel" href="javascript:void(0)"><i class="icon-font"></i>批量删除</a>
                        <%--<a id="updateOrd" href="javascript:void(0)"><i class="icon-font"></i>更新排序</a>--%>
                    </div>
                </div>
                <div class="result-content">

                </div>
        </div>
    </div>
    <!--/main-->
</div>
<jsp:include page="/manage/inc/footer"/>